<?php

function getArgv($argv){
    $arr = [];
    if($argv && is_array($argv)){
        foreach ($argv as $v){
            if(preg_match('/([^=]+)=(.+)/',$v,$out)){
                $arr[$out[1]] = $out[2];
            }
        }
    }
    return $arr;
}
if(!isset($_SERVER['SERVER_NAME'])){
    $param_arr = getArgv($argv);
    $_SERVER['SERVER_NAME'] = $param_arr['e'];
    $_SERVER['HTTP_HOST'] = $param_arr['e'];
}

//测试
if(isset($_SERVER['HTTP_HOST']) && preg_match('/local/',$_SERVER['HTTP_HOST'])){
    return [
        'class' => 'yii\db\Connection',
        'dsn' => 'mysql:host=127.0.0.1;dbname=gptcrawler;port=3306',
        'username' => 'root',
        'password' => 'DRsXT5ZJ6Oi55LPQ',
        'charset' => 'utf8',
    ];
}
//线上
return [
    'class' => 'yii\db\Connection',
    'dsn' => 'mysql:host=127.0.0.1;dbname=gptcrawler;port=3306;charset=utf8mb4',
    'username' => 'gptcrawler',
    'password' => 'wrNG2jZKt6NPDEy4',
    'charset' => 'utf8',
];